package springboot.study.project.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: PicConfig
 * @Description: 图片配置类
 * @Author: liu-hao
 * @Date: 2021-04-18 16:23
 * @Version: 1.0
 **/
//新增加一个类用来添加虚拟路径映射
@Configuration
public class PicConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String uploadPath = System.getProperty("user.dir") + "/src/main/resources/static/upload/";
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + uploadPath);
    }
}